package com.kedacom.ctsp.authz.access;

import com.kedacom.ctsp.authz.entity.AuthPerson;
import com.kedacom.ctsp.authz.entity.Authentication;
import com.kedacom.ctsp.web.entity.CreateDeptNameRecordableBeanWithCode;
import com.kedacom.ctsp.web.entity.CreateDeptRecordableBeanWithCode;
import org.springframework.stereotype.Service;

/**
 * TODO 完成注释
 *
 * @author xuwei
 */
@Service
public class CreateDepartmentRecordableBeanHandler extends RecordableBeanHandlerAdaptor<CreateDeptRecordableBeanWithCode> {

    @Override
    public void handleSilently(CreateDeptRecordableBeanWithCode entity, Authentication auth) {
        AuthPerson person = auth.getPerson();
        if (person != null && person.getDeptCode() != null) {
            entity.setCreateDeptCode(person.getDeptCode());
            if (entity instanceof CreateDeptNameRecordableBeanWithCode) {
                ((CreateDeptNameRecordableBeanWithCode) entity).setCreateDeptName(person.getDeptName());
            }
        }
    }


}
